package com.xhj.xmly.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.xhj.xmly.R;
import com.xhj.xmly.adapter.DiscoverAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by XHJ on 2016/12/2.
 */
public class SubscriptionFragment extends Fragment {
    private ViewPager viewPager;
    private List<Fragment>fragmentList;
    private int[] images = {R.drawable.no_content,R.drawable.no_subscription,R.drawable.no_history};
    private String[] titles = {"推荐","订阅","历史"};
    private DiscoverAdapter subscriptionAdapter;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.subscription_fragment,container,false);
        viewPager = ((ViewPager) view.findViewById(R.id.subscription_viewPager));
        fragmentList = new ArrayList<>();
        for (int i = 0; i < images.length; i++) {
            SubscriptionBaseFragment subscriptionBaseFragment = SubscriptionBaseFragment.newInstance(images[i]);
            fragmentList.add(subscriptionBaseFragment);
        }
        subscriptionAdapter = new DiscoverAdapter(getFragmentManager(),fragmentList,getContext(),titles);
        viewPager.setAdapter(subscriptionAdapter);
        return view;
    }
}
